using UnityEngine;
using UnityEngine.AI; // 添加这一行

public class PlayerMove : MonoBehaviour
{
    private NavMeshAgent navAgent;

    private void Start()
    {
        navAgent = GetComponent<NavMeshAgent>();
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0)) // 移动到鼠标点击位置
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                Debug.Log("点击位置：" + hit.point);
                // 移动到鼠标点击位置
                navAgent.SetDestination(hit.point);
            }
        }
    }
}
